package org.android.tools;

import java.util.Hashtable;

import org.ksoap2.serialization.KvmSerializable;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;

public class User implements KvmSerializable {
	public Integer iduser;
	public UserPermision userPermision;
	public Long fbUid;

	public User() {
	}


	public User(UserPermision userPermision) {
		this.userPermision = userPermision;
	}
	public User(UserPermision userPermision, Long fbUid) {
		this.userPermision = userPermision;
		this.fbUid = fbUid;
	}
	
	public Object getProperty(int arg0) {
		// TODO Auto-generated method stub
		switch(arg0) {
		case 0:
			return fbUid;
		case 1:
			return iduser;
		case 2:
			return userPermision;
		}
		return null;
	}

	public int getPropertyCount() {
		// TODO Auto-generated method stub
		return 3;
	}

	public void getPropertyInfo(int arg0, Hashtable arg1, PropertyInfo arg2) {
		// TODO Auto-generated method stub
		switch(arg0)
        {
        case 0:
        	arg2.type = PropertyInfo.LONG_CLASS;
        	arg2.name = "fbUid";
        	break;
        case 1:
        	arg2.type = PropertyInfo.INTEGER_CLASS;
        	arg2.name = "iduser";
            break;
        case 2:
            arg2.type = new UserPermision().getClass();
            arg2.name = "userPermision";
            break;
        default:break;
        }
	}

	public void setProperty(int arg0, Object arg1) {
		// TODO Auto-generated method stub
		switch(arg0)
        {
        case 0:
        	fbUid = Long.parseLong(arg1.toString());
            break;
        case 1:
        	iduser = Integer.parseInt(arg1.toString());
            break;
        case 2:
        	userPermision = (UserPermision)arg1;
            break;
        default:
            break;
        }
	}
	
	public static User parseUser(SoapObject soap, int arg0)
	{
		SoapObject arg1 = (SoapObject) soap.getProperty(arg0);
		User user = new User();
		user.fbUid = Long.parseLong(arg1.getProperty(0).toString());
		user.iduser = Integer.parseInt(arg1.getProperty(1).toString());
		user.userPermision = UserPermision.parseUserPermision(soap, 2);
		return user;
	}

}
